home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 770 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: news.clark.net!not-for-mail
  2. From: dickey@clark.net (T.E.Dickey)
  3. Newsgroups: comp.std.c
  4. Subject: Re: valueless return statement in non-void function
  5. Date: 20 Apr 1996 11:34:22 GMT
  6. Organization: Clark Internet Services, Inc., Ellicott City, MD USA
  7. Message-ID: <4lai3u$5q2@clarknet.clark.net>
  8. References: <829573502snz@wbriscoe.demon.co.uk>
  9. NNTP-Posting-Host: explorer.clark.net
  10. Mime-Version: 1.0
  11. Content-Type: TEXT/PLAIN; charset=ISO-8859-1
  12. Content-Transfer-Encoding: 8bit
  13. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  14.  
  15. walter briscoe (walter@wbriscoe.demon.co.uk) wrote:
  16. : I recently had trouble moving some K&R code to ISO C.
  17. : Specifically, a function without a return statement was used to return a
  18. : value with an implicit return at the } terminating the function.
  19. ... 
  20. : The obvious objection to such a statement is that it conflicts with
  21. : prior art.  I would answer that by making the implicit type of
  22. : declarations void rather than int.  That would allow less unreasonable
  23. : prior art to port without complaint.  I would have implicitly typed
  24. : declarations deprecated in the next revision of the standard to
  25. : facilitate their removal by a further revision.
  26. Several years ago I ran into more than one instance of code that relied
  27. on (some unspecified C compiler) that would return the last declared
  28. variable if no return-value was given -- I assume the committe had that
  29. one in mind, e.g.,
  30.  
  31.     int foo()
  32.     {
  33.         int x = 4;
  34.         return;    /* implictly returns 4 */
  35.     }
  36.  
  37. (of course I eradicated it from the code, but it would be interesting
  38. to know whose compiler it was written for ;-)
  39.  
  40. -- 
  41. Thomas E. Dickey
  42. dickey@clark.net
  43.